package com.itheima.controller;

import com.itheima.pojo.Account;
import com.itheima.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("account")
public class AccountController {
	@Autowired
	private AccountService accountService;

	@RequestMapping("findAll")
	public String findAll(ModelMap modelMap, ModelAndView modelAndView){
		List<Account> accounts = accountService.findAll();


		for (Account a:accounts
			 ) {
			System.out.println(a);
		}
		//modelMap.addAttribute("accounts",accounts);


		modelMap.addAttribute("accounts",accounts);

		return "list";
	}

}
